package com.shermanzhou.springbootflowable.demo.flow;

import lombok.Builder;
import lombok.Data;
import org.flowable.task.api.TaskInfo;

import java.util.ArrayList;
import java.util.List;

/**
 * @author zhouchaoqun02
 * @date 2020-07-07 10:35
 */
@Data
@Builder
public class ApprovalFlowNode {
    protected String nodeId;
    protected String nodeName;

    protected String executionId;
    protected String collectionVariable;
    protected List<Object> elementVariableValues;

    protected String elementVariable;

    protected List<TaskInfo> taskEntities;

    /**
     * 子流程的审批流，支持多实例子流程
     */
    protected List<ApprovalFlow> subFlows;
    /**
     * 后续审批节点，支持并行节点
     */
    protected List<ApprovalFlowNode> nextNodes;

    public boolean addNextNode(ApprovalFlowNode node) {
        if (nextNodes == null) {
            nextNodes = new ArrayList<>();
        }
        return nextNodes.add(node);
    }

    public boolean addNextNodes(List<ApprovalFlowNode> nodes) {
        if (nextNodes == null) {
            nextNodes = new ArrayList<>();
        }
        return nextNodes.addAll(nodes);
    }
}
